package pwd.allen;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import pwd.allen.service.impl.MyService;

import java.io.IOException;

/**
 * 消费者Consumer会从注册中心中订阅相关的服务，Provider的增加或者下线都可以通过注册中心动态的通知到消费者
 *
 * 原理：
 *  RegistryFactory通过SPI机制根据protocol参数选择不同的协议
 *
 * 核心模块是：dubbo-registry-api，具体实现有：nacos zookeeper redis etcd等
 *
 * {@link org.apache.dubbo.registry.support.AbstractRegistry} 增加缓存机制
 * {@link org.apache.dubbo.registry.support.FailbackRegistry} 增加失败重试功能
 *
 * @author lenovo
 * @create 2019-10-05 16:20
 **/
public class ConsumerMain {
    public static void main(String[] args) throws IOException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
        context.start();

        MyService bean = context.getBean(MyService.class);
        try {
            System.out.println(bean.sayHello("蔡徐坤"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
